import { observable, action, autorun, computed } from "mobx"
import { ajax } from "../../api"

interface UserInfo {
    username: string
    role: number,
    collapsed: any,
    avatar: string
}
class MyInfo {
    // @observable userInfo: UserInfo = {
    //     username: "",
    //     role: 0,
    //     collapsed: false,
    //     avatar: ""
    // }
    //用户信息
    @observable userInfo: any = null  // v-if 
    @observable collapsed: any = false

    // 用户列表
    @observable userList: Array<object> = []



    @action changeInfo = (payload: any) => {
        console.log(payload)
        // console.log(this.userInfo)  // proxy 
        this.userInfo = payload;
    }

    @action changeCollapsed = (collapsed: any) => {
        this.collapsed = !collapsed
        console.log(1111);

    }
    @action getUserListAsync = async (payload: any) => {
        let { code, result }: any = await ajax.getuserlist(payload)
        if (code == 200) {
            this.userList = result
        }

    }

    @action getUserList = (palyoad: any) => {
        this.userList = palyoad
    }

}

const myinfo = new MyInfo()
export default myinfo